<template>
  <div id="main">
    <div class="userTop">
      <p>我的</p>
      <div class="userdata">
        <img src="../../assets/logo.png" alt="" />
        <div class="texts" v-if="!isShow" @click="onIs">
          <p>用户名</p>
          <p>{{ usertel }}</p>
        </div>
        <div class="main_green_user_right" v-if="isShow">
          <p @click="toLogin">请登录</p>
        </div>
      </div>
    </div>
    <div class="myDing">
      <p class="bg1">我的订单</p>
      <p>查看全部订单&gt;</p>
    </div>
    <div class="myDan">
      <ul>
        <li>
          <img src="../../assets/logo.png" alt="" />
          <p>待支付</p>
        </li>
        <li>
          <img src="../../assets/logo.png" alt="" />
          <p>待收货</p>
        </li>
        <li>
          <img src="../../assets/logo.png" alt="" />
          <p>待评价</p>
        </li>
        <li>
          <img src="../../assets/logo.png" alt="" />
          <p>售后/退款</p>
        </li>
      </ul>
    </div>
    <div class="myDing">
      <p class="bg1">我的优惠卷</p>
      <p>2张&gt;</p>
    </div>
    <div class="myDing">
      <p class="bg1">我的收货地址</p>
      <p>&gt;</p>
    </div>
    <div class="myDing myLv">
      <p class="bg1">我的绿卡</p>
      <p>&gt;</p>
    </div>
    <div class="myDing">
      <p class="bg1">联系客服</p>
      <p>客服时间 07:00-22:00&gt;</p>
    </div>
    <div class="myDing">
      <p class="bg1">意见反馈</p>
      <p>&gt;</p>
    </div>
    <van-popup
      v-model="show"
      closeable
      position="right"
      :style="{ height: '100%', width: '100%' }"
    >
      <p class="van_title">个人资料</p>
      <div>
        <p>昵称</p>
        <p>性别</p>
        <p>生日</p>
        <p>{{ usertel }}</p>
        <div class="tuichu" @click="tc">退出登录</div>
      </div>
    </van-popup>
    <!-- <tab-bars></tab-bars> -->
  </div>
</template>

<script>
// import tabBars from "@/components/tabBars.vue";

export default {
  // components: { tabBars },
  name: "MyView",
  data() {
    return {
      isShow: false,
      show: false,
      usertel: "",
    };
  },
  computed: {},
  methods: {
    //去个人信息
    onIs() {
      // this.$router.push("/myis")
      this.show = !this.show;
    },
    tc() {
      this.$dialog
        .confirm({
          title: "退出登录",
          message: "确定退出登录么",
        })
        .then(() => {
          this.show = !this.show;
          this.isShow = !this.isShow;
          localStorage.removeItem("token");
          //  this.$store.state.islogin = false;
          // on confirm
          // this.$router.push("/loginCom")
        })
        .catch(() => {
          // on cancel
        });
    },
    toLogin() {
      this.$router.push("/login");
    },
  },
  created() {
    if (localStorage.getItem("token")) {
      this.usertel = JSON.parse(localStorage.getItem("token")).tel;
    }
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
#main {
  .userTop {
    height: 3rem;
    background: #33B052;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    overflow: hidden;
    p {
      margin: 0.2rem 0 0 0;
      font-size: 0.3rem;
      font-weight: 600;
      text-align: center;
      color: #fff;
    }
    .userdata {
      display: flex;
      align-items: center;
      img {
        width: 2rem;
        height: 2rem;
        border-radius: 50%;
      }
      .texts {
        flex: 1;
        p {
          text-align: left;
          margin-left: 0.2rem;
        }
      }
      .main_green_user_right {
        width: 70%;
        display: flex;
        flex-wrap: wrap;
        align-content: center;
        align-items: center;
        p {
          width: 100%;
          font-size: 18px;
          color: white;
          text-align: left;
          text-indent: 0.1rem;
        }
      }
    }
  }
  .myDing {
    width: 100%;
    height: 0.6rem;
    background: white;
    // border-bottom:1px solid #ccc;
    display: flex;
    justify-content: space-between;
    line-height: 0.6rem;
    margin-top: 0.2rem;
    p {
      font-size: 0.24rem;
      color: #ccc;
      margin: 0 0.2rem;
    }
    .bg1 {
      background: url("../../../ps原图/assets/img/icon/money.png") no-repeat;
      text-indent: 0.6rem;
      color: black;
    }
  }
  .myDan {
    width: 100%;
    margin-top: 0.1rem;
    border-bottom: 10px solid rgb(236, 236, 236);
    height: 1.6rem;
    overflow: hidden;
    ul {
      display: flex;
      margin-top: 0.2rem;
      li {
        width: 25%;
        text-align: center;
        p {
          margin: 0;
          color: grey;
          font-size: 0.26rem;
        }
        img {
          display: block;
          width: 0.6rem;
          margin: 0.1rem auto;
        }
      }
    }
  }
  .van-popup {
    z-index: 10000000;
    background: rgb(245, 245, 245);
    .van_title {
      font-size: 20px;
      background: #fff;
      text-align: center;
      height: 1rem;
      line-height: 1rem;
      margin: 0 0 0.1rem 0;
    }
    div {
      p {
        font-size: 0.3rem;
        margin: 0.1rem 0;
        padding-left: 0.2rem;
        height: 0.8rem;
        font-size: 0.28rem;
        line-height: 0.8rem;
        color: rgb(0, 0, 0);
        border-bottom: 0.01rem solid grey;
        background: #fff;
      }
      .tuichu {
        width: 98%;
        margin: 0 auto;
        height: 0.8rem;
        font-size: 0.24rem;
        border: 1px solid #ccc;
        text-align: center;
        background: #fff;
        line-height: 0.8rem;
      }
    }
  }
}
</style>